import XCTest
import CPU
@testable import Windfish

class InstructionSetTests: XCTestCase {
  func testWidths() {
    let widths: [LR35902.Instruction.Spec: InstructionWidth<UInt16>] = [
      .nop: InstructionWidth(opcode: 1, operand: 0),
      .ld(.bc, .imm16): InstructionWidth(opcode: 1, operand: 2),
      .ld(.bcaddr, .a): InstructionWidth(opcode: 1, operand: 0),
      .inc(.bc): InstructionWidth(opcode: 1, operand: 0),
      .inc(.b): InstructionWidth(opcode: 1, operand: 0),
      .dec(.b): InstructionWidth(opcode: 1, operand: 0),
      .ld(.b, .imm8): InstructionWidth(opcode: 1, operand: 1),
      .rlca: InstructionWidth(opcode: 1, operand: 0),
      .ld(.imm16addr, .sp): InstructionWidth(opcode: 1, operand: 2),
      .add(.hl, .bc): InstructionWidth(opcode: 1, operand: 0),
      .ld(.a, .bcaddr): InstructionWidth(opcode: 1, operand: 0),
      .dec(.bc): InstructionWidth(opcode: 1, operand: 0),
      .inc(.c): InstructionWidth(opcode: 1, operand: 0),
      .dec(.c): InstructionWidth(opcode: 1, operand: 0),
      .ld(.c, .imm8): InstructionWidth(opcode: 1, operand: 1),
      .rrca: InstructionWidth(opcode: 1, operand: 0),

      .stop(.zeroimm8): InstructionWidth(opcode: 1, operand: 1),
      .ld(.de, .imm16): InstructionWidth(opcode: 1, operand: 2),
      .ld(.deaddr, .a): InstructionWidth(opcode: 1, operand: 0),
      .inc(.de): InstructionWidth(opcode: 1, operand: 0),
      .inc(.d): InstructionWidth(opcode: 1, operand: 0),
      .dec(.d): InstructionWidth(opcode: 1, operand: 0),
      .ld(.d, .imm8): InstructionWidth(opcode: 1, operand: 1),
      .rla: InstructionWidth(opcode: 1, operand: 0),
      .jr(nil, .simm8): InstructionWidth(opcode: 1, operand: 1),
      .add(.hl, .de): InstructionWidth(opcode: 1, operand: 0),
      .ld(.a, .deaddr): InstructionWidth(opcode: 1, operand: 0),
      .dec(.de): InstructionWidth(opcode: 1, operand: 0),
      .inc(.e): InstructionWidth(opcode: 1, operand: 0),
      .dec(.e): InstructionWidth(opcode: 1, operand: 0),
      .ld(.e, .imm8): InstructionWidth(opcode: 1, operand: 1),
      .rra: InstructionWidth(opcode: 1, operand: 0),

      .jr(.nz, .simm8): InstructionWidth(opcode: 1, operand: 1),
      .ld(.hl, .imm16): InstructionWidth(opcode: 1, operand: 2),
      .ldi(.hladdr, .a): InstructionWidth(opcode: 1, operand: 0),
      .inc(.hl): InstructionWidth(opcode: 1, operand: 0),
      .inc(.h): InstructionWidth(opcode: 1, operand: 0),
      .dec(.h): InstructionWidth(opcode: 1, operand: 0),
      .ld(.h, .imm8): InstructionWidth(opcode: 1, operand: 1),
      .daa: InstructionWidth(opcode: 1, operand: 0),
      .jr(.z, .simm8): InstructionWidth(opcode: 1, operand: 1),
      .add(.hl, .hl): InstructionWidth(opcode: 1, operand: 0),
      .ldi(.a, .hladdr): InstructionWidth(opcode: 1, operand: 0),
      .dec(.hl): InstructionWidth(opcode: 1, operand: 0),
      .inc(.l): InstructionWidth(opcode: 1, operand: 0),
      .dec(.l): InstructionWidth(opcode: 1, operand: 0),
      .ld(.l, .imm8): InstructionWidth(opcode: 1, operand: 1),
      .cpl: InstructionWidth(opcode: 1, operand: 0),

      .jr(.nc, .simm8): InstructionWidth(opcode: 1, operand: 1),
      .ld(.sp, .imm16): InstructionWidth(opcode: 1, operand: 2),
      .ldd(.hladdr, .a): InstructionWidth(opcode: 1, operand: 0),
      .inc(.sp): InstructionWidth(opcode: 1, operand: 0),
      .inc(.hladdr): InstructionWidth(opcode: 1, operand: 0),
      .dec(.hladdr): InstructionWidth(opcode: 1, operand: 0),
      .ld(.hladdr, .imm8): InstructionWidth(opcode: 1, operand: 1),
      .scf: InstructionWidth(opcode: 1, operand: 0),
      .jr(.c, .simm8): InstructionWidth(opcode: 1, operand: 1),
      .add(.hl, .sp): InstructionWidth(opcode: 1, operand: 0),
      .ldd(.a, .hladdr): InstructionWidth(opcode: 1, operand: 0),
      .dec(.sp): InstructionWidth(opcode: 1, operand: 0),
      .inc(.a): InstructionWidth(opcode: 1, operand: 0),
      .dec(.a): InstructionWidth(opcode: 1, operand: 0),
      .ld(.a, .imm8): InstructionWidth(opcode: 1, operand: 1),
      .ccf: InstructionWidth(opcode: 1, operand: 0),

      .ld(.b, .b): InstructionWidth(opcode: 1, operand: 0),
      .ld(.b, .c): InstructionWidth(opcode: 1, operand: 0),
      .ld(.b, .d): InstructionWidth(opcode: 1, operand: 0),
      .ld(.b, .e): InstructionWidth(opcode: 1, operand: 0),
      .ld(.b, .h): InstructionWidth(opcode: 1, operand: 0),
      .ld(.b, .l): InstructionWidth(opcode: 1, operand: 0),
      .ld(.b, .hladdr): InstructionWidth(opcode: 1, operand: 0),
      .ld(.b, .a): InstructionWidth(opcode: 1, operand: 0),
      .ld(.c, .b): InstructionWidth(opcode: 1, operand: 0),
      .ld(.c, .c): InstructionWidth(opcode: 1, operand: 0),
      .ld(.c, .d): InstructionWidth(opcode: 1, operand: 0),
      .ld(.c, .e): InstructionWidth(opcode: 1, operand: 0),
      .ld(.c, .h): InstructionWidth(opcode: 1, operand: 0),
      .ld(.c, .l): InstructionWidth(opcode: 1, operand: 0),
      .ld(.c, .hladdr): InstructionWidth(opcode: 1, operand: 0),
      .ld(.c, .a): InstructionWidth(opcode: 1, operand: 0),

      .ld(.d, .b): InstructionWidth(opcode: 1, operand: 0),
      .ld(.d, .c): InstructionWidth(opcode: 1, operand: 0),
      .ld(.d, .d): InstructionWidth(opcode: 1, operand: 0),
      .ld(.d, .e): InstructionWidth(opcode: 1, operand: 0),
      .ld(.d, .h): InstructionWidth(opcode: 1, operand: 0),
      .ld(.d, .l): InstructionWidth(opcode: 1, operand: 0),
      .ld(.d, .hladdr): InstructionWidth(opcode: 1, operand: 0),
      .ld(.d, .a): InstructionWidth(opcode: 1, operand: 0),
      .ld(.e, .b): InstructionWidth(opcode: 1, operand: 0),
      .ld(.e, .c): InstructionWidth(opcode: 1, operand: 0),
      .ld(.e, .d): InstructionWidth(opcode: 1, operand: 0),
      .ld(.e, .e): InstructionWidth(opcode: 1, operand: 0),
      .ld(.e, .h): InstructionWidth(opcode: 1, operand: 0),
      .ld(.e, .l): InstructionWidth(opcode: 1, operand: 0),
      .ld(.e, .hladdr): InstructionWidth(opcode: 1, operand: 0),
      .ld(.e, .a): InstructionWidth(opcode: 1, operand: 0),

      .ld(.h, .b): InstructionWidth(opcode: 1, operand: 0),
      .ld(.h, .c): InstructionWidth(opcode: 1, operand: 0),
      .ld(.h, .d): InstructionWidth(opcode: 1, operand: 0),
      .ld(.h, .e): InstructionWidth(opcode: 1, operand: 0),
      .ld(.h, .h): InstructionWidth(opcode: 1, operand: 0),
      .ld(.h, .l): InstructionWidth(opcode: 1, operand: 0),
      .ld(.h, .hladdr): InstructionWidth(opcode: 1, operand: 0),
      .ld(.h, .a): InstructionWidth(opcode: 1, operand: 0),
      .ld(.l, .b): InstructionWidth(opcode: 1, operand: 0),
      .ld(.l, .c): InstructionWidth(opcode: 1, operand: 0),
      .ld(.l, .d): InstructionWidth(opcode: 1, operand: 0),
      .ld(.l, .e): InstructionWidth(opcode: 1, operand: 0),
      .ld(.l, .h): InstructionWidth(opcode: 1, operand: 0),
      .ld(.l, .l): InstructionWidth(opcode: 1, operand: 0),
      .ld(.l, .hladdr): InstructionWidth(opcode: 1, operand: 0),
      .ld(.l, .a): InstructionWidth(opcode: 1, operand: 0),

      .ld(.hladdr, .b): InstructionWidth(opcode: 1, operand: 0),
      .ld(.hladdr, .c): InstructionWidth(opcode: 1, operand: 0),
      .ld(.hladdr, .d): InstructionWidth(opcode: 1, operand: 0),
      .ld(.hladdr, .e): InstructionWidth(opcode: 1, operand: 0),
      .ld(.hladdr, .h): InstructionWidth(opcode: 1, operand: 0),
      .ld(.hladdr, .l): InstructionWidth(opcode: 1, operand: 0),
      .halt: InstructionWidth(opcode: 1, operand: 0),
      .ld(.hladdr, .a): InstructionWidth(opcode: 1, operand: 0),
      .ld(.a, .b): InstructionWidth(opcode: 1, operand: 0),
      .ld(.a, .c): InstructionWidth(opcode: 1, operand: 0),
      .ld(.a, .d): InstructionWidth(opcode: 1, operand: 0),
      .ld(.a, .e): InstructionWidth(opcode: 1, operand: 0),
      .ld(.a, .h): InstructionWidth(opcode: 1, operand: 0),
      .ld(.a, .l): InstructionWidth(opcode: 1, operand: 0),
      .ld(.a, .hladdr): InstructionWidth(opcode: 1, operand: 0),
      .ld(.a, .a): InstructionWidth(opcode: 1, operand: 0),

      .add(.a, .b): InstructionWidth(opcode: 1, operand: 0),
      .add(.a, .c): InstructionWidth(opcode: 1, operand: 0),
      .add(.a, .d): InstructionWidth(opcode: 1, operand: 0),
      .add(.a, .e): InstructionWidth(opcode: 1, operand: 0),
      .add(.a, .h): InstructionWidth(opcode: 1, operand: 0),
      .add(.a, .l): InstructionWidth(opcode: 1, operand: 0),
      .add(.a, .hladdr): InstructionWidth(opcode: 1, operand: 0),
      .add(.a, .a): InstructionWidth(opcode: 1, operand: 0),
      .adc(.b): InstructionWidth(opcode: 1, operand: 0),
      .adc(.c): InstructionWidth(opcode: 1, operand: 0),
      .adc(.d): InstructionWidth(opcode: 1, operand: 0),
      .adc(.e): InstructionWidth(opcode: 1, operand: 0),
      .adc(.h): InstructionWidth(opcode: 1, operand: 0),
      .adc(.l): InstructionWidth(opcode: 1, operand: 0),
      .adc(.hladdr): InstructionWidth(opcode: 1, operand: 0),
      .adc(.a): InstructionWidth(opcode: 1, operand: 0),

      .sub(.a, .b): InstructionWidth(opcode: 1, operand: 0),
      .sub(.a, .c): InstructionWidth(opcode: 1, operand: 0),
      .sub(.a, .d): InstructionWidth(opcode: 1, operand: 0),
      .sub(.a, .e): InstructionWidth(opcode: 1, operand: 0),
      .sub(.a, .h): InstructionWidth(opcode: 1, operand: 0),
      .sub(.a, .l): InstructionWidth(opcode: 1, operand: 0),
      .sub(.a, .hladdr): InstructionWidth(opcode: 1, operand: 0),
      .sub(.a, .a): InstructionWidth(opcode: 1, operand: 0),
      .sbc(.b): InstructionWidth(opcode: 1, operand: 0),
      .sbc(.c): InstructionWidth(opcode: 1, operand: 0),
      .sbc(.d): InstructionWidth(opcode: 1, operand: 0),
      .sbc(.e): InstructionWidth(opcode: 1, operand: 0),
      .sbc(.h): InstructionWidth(opcode: 1, operand: 0),
      .sbc(.l): InstructionWidth(opcode: 1, operand: 0),
      .sbc(.hladdr): InstructionWidth(opcode: 1, operand: 0),
      .sbc(.a): InstructionWidth(opcode: 1, operand: 0),

      .and(.b): InstructionWidth(opcode: 1, operand: 0),
      .and(.c): InstructionWidth(opcode: 1, operand: 0),
      .and(.d): InstructionWidth(opcode: 1, operand: 0),
      .and(.e): InstructionWidth(opcode: 1, operand: 0),
      .and(.h): InstructionWidth(opcode: 1, operand: 0),
      .and(.l): InstructionWidth(opcode: 1, operand: 0),
      .and(.hladdr): InstructionWidth(opcode: 1, operand: 0),
      .and(.a): InstructionWidth(opcode: 1, operand: 0),
      .xor(.b): InstructionWidth(opcode: 1, operand: 0),
      .xor(.c): InstructionWidth(opcode: 1, operand: 0),
      .xor(.d): InstructionWidth(opcode: 1, operand: 0),
      .xor(.e): InstructionWidth(opcode: 1, operand: 0),
      .xor(.h): InstructionWidth(opcode: 1, operand: 0),
      .xor(.l): InstructionWidth(opcode: 1, operand: 0),
      .xor(.hladdr): InstructionWidth(opcode: 1, operand: 0),
      .xor(.a): InstructionWidth(opcode: 1, operand: 0),

      .or(.b): InstructionWidth(opcode: 1, operand: 0),
      .or(.c): InstructionWidth(opcode: 1, operand: 0),
      .or(.d): InstructionWidth(opcode: 1, operand: 0),
      .or(.e): InstructionWidth(opcode: 1, operand: 0),
      .or(.h): InstructionWidth(opcode: 1, operand: 0),
      .or(.l): InstructionWidth(opcode: 1, operand: 0),
      .or(.hladdr): InstructionWidth(opcode: 1, operand: 0),
      .or(.a): InstructionWidth(opcode: 1, operand: 0),
      .cp(.b): InstructionWidth(opcode: 1, operand: 0),
      .cp(.c): InstructionWidth(opcode: 1, operand: 0),
      .cp(.d): InstructionWidth(opcode: 1, operand: 0),
      .cp(.e): InstructionWidth(opcode: 1, operand: 0),
      .cp(.h): InstructionWidth(opcode: 1, operand: 0),
      .cp(.l): InstructionWidth(opcode: 1, operand: 0),
      .cp(.hladdr): InstructionWidth(opcode: 1, operand: 0),
      .cp(.a): InstructionWidth(opcode: 1, operand: 0),

      .ret(.nz): InstructionWidth(opcode: 1, operand: 0),
      .pop(.bc): InstructionWidth(opcode: 1, operand: 0),
      .jp(.nz, .imm16): InstructionWidth(opcode: 1, operand: 2),
      .jp(nil, .imm16): InstructionWidth(opcode: 1, operand: 2),
      .call(.nz, .imm16): InstructionWidth(opcode: 1, operand: 2),
      .push(.bc): InstructionWidth(opcode: 1, operand: 0),
      .add(.a, .imm8): InstructionWidth(opcode: 1, operand: 1),
      .rst(.x00): InstructionWidth(opcode: 1, operand: 0),
      .ret(.z): InstructionWidth(opcode: 1, operand: 0),
      .ret(): InstructionWidth(opcode: 1, operand: 0),
      .jp(.z, .imm16): InstructionWidth(opcode: 1, operand: 2),
      .prefix(.cb): InstructionWidth(opcode: 1, operand: 0),
      .call(.z, .imm16): InstructionWidth(opcode: 1, operand: 2),
      .call(nil, .imm16): InstructionWidth(opcode: 1, operand: 2),
      .adc(.imm8): InstructionWidth(opcode: 1, operand: 1),
      .rst(.x08): InstructionWidth(opcode: 1, operand: 0),

      .ret(.nc): InstructionWidth(opcode: 1, operand: 0),
      .pop(.de): InstructionWidth(opcode: 1, operand: 0),
      .jp(.nc, .imm16): InstructionWidth(opcode: 1, operand: 2),
      .call(.nc, .imm16): InstructionWidth(opcode: 1, operand: 2),
      .push(.de): InstructionWidth(opcode: 1, operand: 0),
      .sub(.a, .imm8): InstructionWidth(opcode: 1, operand: 1),
      .rst(.x10): InstructionWidth(opcode: 1, operand: 0),
      .ret(.c): InstructionWidth(opcode: 1, operand: 0),
      .reti: InstructionWidth(opcode: 1, operand: 0),
      .jp(.c, .imm16): InstructionWidth(opcode: 1, operand: 2),
      .call(.c, .imm16): InstructionWidth(opcode: 1, operand: 2),
      .sbc(.imm8): InstructionWidth(opcode: 1, operand: 1),
      .rst(.x18): InstructionWidth(opcode: 1, operand: 0),

      .ld(.ffimm8addr, .a): InstructionWidth(opcode: 1, operand: 1),
      .pop(.hl): InstructionWidth(opcode: 1, operand: 0),
      .ld(.ffccaddr, .a): InstructionWidth(opcode: 1, operand: 0),
      .push(.hl): InstructionWidth(opcode: 1, operand: 0),
      .and(.imm8): InstructionWidth(opcode: 1, operand: 1),
      .rst(.x20): InstructionWidth(opcode: 1, operand: 0),
      .add(.sp, .imm8): InstructionWidth(opcode: 1, operand: 1),
      .jp(nil, .hl): InstructionWidth(opcode: 1, operand: 0),
      .ld(.imm16addr, .a): InstructionWidth(opcode: 1, operand: 2),
      .xor(.imm8): InstructionWidth(opcode: 1, operand: 1),
      .rst(.x28): InstructionWidth(opcode: 1, operand: 0),

      .ld(.a, .ffimm8addr): InstructionWidth(opcode: 1, operand: 1),
      .pop(.af): InstructionWidth(opcode: 1, operand: 0),
      .ld(.a, .ffccaddr): InstructionWidth(opcode: 1, operand: 0),
      .di: InstructionWidth(opcode: 1, operand: 0),
      .push(.af): InstructionWidth(opcode: 1, operand: 0),
      .or(.imm8): InstructionWidth(opcode: 1, operand: 1),
      .rst(.x30): InstructionWidth(opcode: 1, operand: 0),
      .ld(.hl, .sp_plus_simm8): InstructionWidth(opcode: 1, operand: 1),
      .ld(.sp, .hl): InstructionWidth(opcode: 1, operand: 0),
      .ld(.a, .imm16addr): InstructionWidth(opcode: 1, operand: 2),
      .ei: InstructionWidth(opcode: 1, operand: 0),
      .cp(.imm8): InstructionWidth(opcode: 1, operand: 1),
      .rst(.x38): InstructionWidth(opcode: 1, operand: 0),

      .invalid: InstructionWidth(opcode: 1, operand: 0),

      .cb(.rlc(.b)): InstructionWidth(opcode: 2, operand: 0),
        .cb(.rlc(.c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rlc(.d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rlc(.e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rlc(.h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rlc(.l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rlc(.hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rlc(.a)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rrc(.b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rrc(.c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rrc(.d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rrc(.e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rrc(.h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rrc(.l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rrc(.hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rrc(.a)): InstructionWidth(opcode: 2, operand: 0),

      .cb(.rl(.b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rl(.c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rl(.d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rl(.e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rl(.h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rl(.l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rl(.hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rl(.a)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rr(.b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rr(.c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rr(.d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rr(.e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rr(.h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rr(.l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rr(.hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.rr(.a)): InstructionWidth(opcode: 2, operand: 0),

      .cb(.sla(.b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.sla(.c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.sla(.d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.sla(.e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.sla(.h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.sla(.l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.sla(.hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.sla(.a)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.sra(.b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.sra(.c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.sra(.d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.sra(.e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.sra(.h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.sra(.l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.sra(.hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.sra(.a)): InstructionWidth(opcode: 2, operand: 0),

      .cb(.swap(.b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.swap(.c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.swap(.d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.swap(.e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.swap(.h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.swap(.l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.swap(.hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.swap(.a)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.srl(.b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.srl(.c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.srl(.d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.srl(.e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.srl(.h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.srl(.l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.srl(.hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.srl(.a)): InstructionWidth(opcode: 2, operand: 0),

      .cb(.bit(.b0, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b0, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b0, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b0, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b0, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b0, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b0, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b0, .a)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b1, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b1, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b1, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b1, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b1, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b1, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b1, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b1, .a)): InstructionWidth(opcode: 2, operand: 0),

      .cb(.bit(.b2, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b2, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b2, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b2, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b2, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b2, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b2, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b2, .a)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b3, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b3, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b3, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b3, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b3, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b3, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b3, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b3, .a)): InstructionWidth(opcode: 2, operand: 0),

      .cb(.bit(.b4, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b4, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b4, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b4, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b4, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b4, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b4, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b4, .a)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b5, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b5, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b5, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b5, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b5, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b5, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b5, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b5, .a)): InstructionWidth(opcode: 2, operand: 0),

      .cb(.bit(.b6, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b6, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b6, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b6, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b6, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b6, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b6, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b6, .a)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b7, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b7, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b7, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b7, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b7, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b7, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b7, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.bit(.b7, .a)): InstructionWidth(opcode: 2, operand: 0),

      .cb(.res(.b0, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b0, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b0, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b0, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b0, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b0, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b0, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b0, .a)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b1, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b1, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b1, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b1, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b1, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b1, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b1, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b1, .a)): InstructionWidth(opcode: 2, operand: 0),

      .cb(.res(.b2, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b2, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b2, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b2, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b2, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b2, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b2, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b2, .a)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b3, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b3, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b3, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b3, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b3, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b3, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b3, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b3, .a)): InstructionWidth(opcode: 2, operand: 0),

      .cb(.res(.b4, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b4, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b4, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b4, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b4, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b4, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b4, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b4, .a)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b5, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b5, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b5, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b5, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b5, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b5, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b5, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b5, .a)): InstructionWidth(opcode: 2, operand: 0),

      .cb(.res(.b6, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b6, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b6, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b6, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b6, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b6, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b6, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b6, .a)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b7, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b7, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b7, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b7, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b7, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b7, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b7, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.res(.b7, .a)): InstructionWidth(opcode: 2, operand: 0),

      .cb(.set(.b0, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b0, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b0, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b0, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b0, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b0, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b0, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b0, .a)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b1, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b1, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b1, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b1, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b1, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b1, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b1, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b1, .a)): InstructionWidth(opcode: 2, operand: 0),

      .cb(.set(.b2, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b2, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b2, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b2, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b2, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b2, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b2, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b2, .a)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b3, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b3, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b3, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b3, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b3, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b3, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b3, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b3, .a)): InstructionWidth(opcode: 2, operand: 0),

      .cb(.set(.b4, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b4, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b4, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b4, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b4, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b4, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b4, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b4, .a)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b5, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b5, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b5, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b5, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b5, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b5, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b5, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b5, .a)): InstructionWidth(opcode: 2, operand: 0),

      .cb(.set(.b6, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b6, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b6, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b6, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b6, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b6, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b6, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b6, .a)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b7, .b)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b7, .c)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b7, .d)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b7, .e)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b7, .h)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b7, .l)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b7, .hladdr)): InstructionWidth(opcode: 2, operand: 0),
      .cb(.set(.b7, .a)): InstructionWidth(opcode: 2, operand: 0),
    ]
    for (key, value) in LR35902.InstructionSet.widths {
      XCTAssertEqual(value, widths[key], "\(key) mismatched")
    }
  }
}
